import '../../utils/concrete'

export function selectBaseroads(query, formData) {
  const data = {
    condition: {
      roadname: formData.road_name,
      ssdw: formData.area_no,
      tcwz: formData.park_location,
      tcsd: formData.park_time,
      isFan: formData.is_fan
    },
    num: query.page,
    pageSize: query.limit
  }
  return concrete.module('BaseroadService').selectBaseroads(data)
}

export function addTollRoad(formData) {
  const data = {
    roadno: '', //
    roadname: formData.road_name,
    ssdw: formData.ssdw_no,
    ssdwname: formData.ssdw, //
    roadstatus: '',
    parknum: formData.park_num,
    placenum: formData.berth_num,
    qzddname: formData.start_end,
    roadtype: formData.type,
    roadkind: formData.is_fan,
    tcwz: formData.location,
    tcsd: formData.time,
    road_longe: formData.end_lon,
    road_latie: formData.end_lat,
    road_longs: formData.start_lon,
    road_latis: formData.start_lat,
    remark: formData.remark
  }
  return concrete.module('BaseroadService').addBaseroad(data)
}

export function editTollRoad(formData) {
  const data = {
    roadno: formData.road_no, //
    roadname: formData.road_name,
    ssdw: formData.ssdw_no,
    ssdwname: formData.ssdw,
    roadstatus: '',
    parknum: formData.park_num,
    placenum: formData.berth_num,
    qzddname: formData.start_end,
    roadtype: formData.type,
    roadkind: formData.is_fan,
    tcwz: formData.location,
    tcsd: formData.time,
    remark: formData.remark
  }
  return concrete.module('BaseroadService').updateBaseroad(data)
}

export function delBaseRoad(dataTable) {
  const data = []
  for (const i in dataTable) {
    data.push(dataTable[i].roadno)
  }
  return concrete.module('BaseroadService').delBaseroads(data)
}
